<script src="Libraries/js/js.js"></script>
<?php
	include_once('Models/HocPhan.php');
	include_once('Configs/paging.php');
    include_once('Configs/database.php');
	include_once('Models/HocKiNamHoc.php');
?>
<script language="javascript">
	function checkField(){
		if(document.xemkhoiluonggiangday.rdohknh.checked == false && document.xemkhoiluonggiangday.rdonam.checked == false){
			alert ("Xin chọn tiêu chí cần xem!");
			return false;
		}
		else{
			if (document.xemkhoiluonggiangday.rdohknh.checked == true)
			{
				if (document.xemkhoiluonggiangday.cbonamhoc.selectedIndex == 0 || document.xemkhoiluonggiangday.cbohocki.selectedIndex == 0){
					alert ("Xin chọn năm học!");
					return false;
				}
				if (document.xemkhoiluonggiangday.cbohocki.selectedIndex == 0){
					alert ("Xin chọn học kì!");
					return false;
				}
			}
			if (document.xemkhoiluonggiangday.rdonam.checked == true)
			{
				if (document.xemkhoiluonggiangday.cbonam.selectedIndex == 0){
					alert ("Xin chọn học năm học!");
					return false;
				}
			}
		}
		return true;
	}
	function checkChonHKNH(){
		document.xemkhoiluonggiangday.cbonam.selectedIndex = 0;
		document.xemkhoiluonggiangday.cbonam.disabled = true;
		document.xemkhoiluonggiangday.rdonam.checked  = false;
		
		document.xemkhoiluonggiangday.cbonamhoc.disabled = false;
		document.xemkhoiluonggiangday.cbohocki.disabled = false;
			
		
		
			
			
		
		
		
	}
	function checkChonNam(){
		document.xemkhoiluonggiangday.cbonamhoc.selectedIndex = 0;
		document.xemkhoiluonggiangday.cbohocki.selectedIndex = 0;
		document.xemkhoiluonggiangday.cbonam.disabled = false;
		document.xemkhoiluonggiangday.rdohknh.checked  = false;
			//document.xemkhoiluonggiangday.rdohknh.checked == true;
			
		document.xemkhoiluonggiangday.cbonamhoc.disabled = true;
		document.xemkhoiluonggiangday.cbohocki.disabled = true;
		
		
		
	}
	function wopen(url, name, w, h){
	  w += 32;
	  h += 96;
	  wleft = (screen.width - w) / 2;
	  wtop = (screen.height - h) / 2;
	  
	  if (wleft < 0) {
		w = screen.width;
		wleft = 0;
	  }
	  if (wtop < 0) {
		h = screen.height;
		wtop = 0;
	  }
	  var win = window.open(url,
		name,
		'width=' + w + ', height=' + h + ', ' +
		'left=' + wleft + ', top=' + wtop + ', ' +
		'location=no, menubar=no, ' +
		'status=no, toolbar=no, scrollbars=yes, resizable=no');
	  // Just in case width and height are ignored
	  win.resizeTo(w, h);
	  // Just in case left and top are ignored
	  win.moveTo(wleft, wtop);
	  win.focus();
}
function printTL(namhoc,hocki,maso){
	
	wopen('inkhoiluonggiangday.php?namhoc='+namhoc+'&hocki='+hocki+'&maso='+maso+'','780','580');
} 
	
</script>
<form name="xemkhoiluonggiangday" method="POST">
<table align="center" class="font" width="800" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class=main_1><img border="0" src="Libraries/images/tbl_left.gif" width="10" height="25" /></td>
    <td align=center class=main_1>Xem Khối Lượng Giảng Dạy </td>
    <td class=main_1><p align="right"><img border="0" src="Libraries/images/tbl_right.gif" width="10" height="25" /></p></td>
  </tr>
  <tr bgcolor="#dae9f3">
    <td class="border_1" colspan="3" valign="top">
        	<table border="0" align="center"  >
                <tr>
                    <td >&nbsp;</td>
                </tr>
			</table>
            <table border="0" align="center"  >
               
                <tr>
                    <td align=right><label>Theo năm
                      <input type="radio" name="rdonam" onClick="checkChonNam();" />
                    </label></td>
                    <td align="left">Năm</td>
                    <td align="left"><select name="cbonam">
                      <option value=" "></option>
                      <?php
										$hknh = new HocKiNamHoc();
                                		$result = $hknh->dsNamHoc();
                                		while ($rows=mysql_fetch_array($result)){
											$i = substr(trim($rows['namhoc']),5,4);
                                    		echo "<option value='".$i."'";				
				                    		echo ">".$i."</option>";
                                		}
                                		if (isset($_POST['cbonam'])){
                                    		echo "<script language=\"javascript\">for(var i=0;i<document.xemkhoiluonggiangday.cbonam.length;i++){if(document.xemkhoiluonggiangday.cbonam[i].value=='$nam'){document.xemkhoiluonggiangday.cbonam.selectedIndex=i;break;}}</script>";
                                		}
                                	?>
                    </select></td>
                    <td align="left">&nbsp;</td>
                </tr>
                <tr>
                  <td align=right>Theo học kì
                  <input type="radio" name="rdohknh"  onClick="checkChonHKNH();" /></td>
                  <td align=right><label>Năm học </label>
                  &nbsp;</td>
                  <td align=right><select name="cbonamhoc">
                    <option value=" "></option>
                    <?php
										$hknh = new HocKiNamHoc();
                                		$result = $hknh->dsNamHoc();
                                		while ($rows=mysql_fetch_array($result)){
                                    		echo "<option value='".$rows['namhoc']."'";				
				                    		echo ">".$rows['namhoc']."</option>";
                                		}
                                		if (isset($_POST['cbonamhoc'])){
                                    		echo "<script language=\"javascript\">for(var i=0;i<document.xemkhoiluonggiangday.cbonamhoc.length;i++){if(document.xemkhoiluonggiangday.cbonamhoc[i].value=='$namhoc'){document.xemkhoiluonggiangday.cbonamhoc.selectedIndex=i;break;}}</script>";
                                		}
                                	?>
                  </select></td>
                  <td align=right>&nbsp;Học kì&nbsp;
                    <select name="cbohocki" >
					<option value=" "></option>
                      <option value="1" <?php if ($_POST['cbohocki']==1) echo "selected='selected'"; ?>>1</option>
                      
  
                      ;
                            
                      
  
                      <option value="2" <?php if ($_POST['cbohocki']==2) echo "selected='selected'"; ?>>2</option>
                      
  
                      ;
							
                      
  
                      <option value="3" <?php if ($_POST['cbohocki']==3) echo "selected='selected'"; ?>>Hè</option>
                      
  
                      ;      
                        
                    
                    

                    </select>
&nbsp;
<?php 
						if ($_SESSION['nmaquyen']=='AD')
                        {
                            
                            echo "MSCB&nbsp;<input type='text' name='txtmaso' size='10'/>";
                        }
                        if ($_SESSION['nmaquyen']=='BM'){
                            $db = new database();
                            $db->setQuery("select a.mabm from CanBoGiangDay a,BoMon b where maso='".$_SESSION['nmaso']."' and a.mabm=b.mabm");
                            $result = $db->fetchAll();
                            $rows = mysql_fetch_array($result);
                            $mabm = $rows['mabm'];
                            $db->setQuery("select a.maso,concat(holot,' ',ten) as hoten from CanBoGiangDay a, CanBo b where a.mabm='".$mabm."' and a.maso=b.maso");
                            $resultcb = $db->fetchAll();
                            echo "Cán Bộ&nbsp;<select name='cbomaso'>";
                            echo "<option value=' '></option>";
                            while($rowscb = mysql_fetch_array($resultcb)){
                                 echo "<option value='".$rowscb['maso']."'>".$rowscb['hoten']."</option>";
                            }
                            echo "</select>";
                        }
                        if ($_SESSION['nmaquyen']=='DV'){
                            $db = new database();
                            $db->setQuery("select b.makhoa from CanBoGiangDay a,BoMon b,Khoa c where maso='".$_SESSION['nmaso']."' and a.mabm=b.mabm and b.makhoa=c.makhoa");
                            $result = $db->fetchAll();
                            $rows = mysql_fetch_array($result);
                            $makhoa = $rows['makhoa'];
                            $db->setQuery("select a.maso,concat(holot,' ',ten) as hoten  from CanBoGiangDay a,BoMon b,Khoa c,Canbo d where b.makhoa='".$makhoa."' and a.mabm=b.mabm and b.makhoa=c.makhoa and a.maso=d.maso");
                            $resultcb = $db->fetchAll();
                            echo "Cán Bộ&nbsp;<select name='cbomaso'>";
                            echo "<option value=' '></option>";
                            while($rowscb = mysql_fetch_array($resultcb)){
                                 echo "<option value='".$rowscb['maso']."'>".$rowscb['hoten']."</option>";
                            }
                            echo "</select>";
                        }
					?></td>
                </tr>
            </table>
       		<table border="0" align="center"  >
                <tr>
       	          <td align=center><label></label>
			      <input type="submit" name="btnxem" value="Xem" class="button_1" onclick="return checkField();"/></td>
                </tr>
			</table>
           

    </td>
  </tr>
</table>

<p>&nbsp;</p>



<?php
	if (isset($_POST['btnxem']) && strlen(trim($namhoc)) > 0){
		require('Hienthikhoiluonggiangday.php');
	}
	if (strlen(trim($nam))>0) require('Hienthikhoiluonggiangday_theonam.php');
?>  
 </form>

<p>&nbsp;</p>
<p>&nbsp;</p>
